#include "ScnsW25qxx.c.h"

#if defined(SCNS_W25QXX_ENABLE)&&SCNS_W25QXX_ENABLE==1

#include "spi.h"

const ScnsBspW25qxxConfig scnsBspW25qxxConfig[SCNS_W25QXX_MAX]={
    {.isQspi=0,},
};

ScnsStatus scnsBspW25qxxSpiW(ScnsW25qxxEnum w25N,const uint8*val,uint32 num)
{
    HAL_StatusTypeDef sta=HAL_SPI_Transmit(&hspi2,(uint8*)val,num,500);
    return sta==HAL_OK?SCNS_STATUS_OK:SCNS_STATUS_BSP_FAILED;
}

ScnsStatus scnsBspW25qxxSpiWR(ScnsW25qxxEnum w25N,const uint8*val,uint32 num,uint8*val2,uint32 num2)
{
    HAL_StatusTypeDef sta=HAL_SPI_Transmit(&hspi2,(uint8*)val,num,500);
    if(sta==HAL_OK)
        sta=HAL_SPI_Receive(&hspi2,val2,num2,500);
    return sta==HAL_OK?SCNS_STATUS_OK:SCNS_STATUS_BSP_FAILED;
}

ScnsStatus scnsBspW25qxxSpiWW(ScnsW25qxxEnum w25N,const uint8*val,uint32 num,const uint8*val2,uint32 num2)
{
    HAL_StatusTypeDef sta=HAL_SPI_Transmit(&hspi2,(uint8*)val,num,500);
    if(sta==HAL_OK)
        sta=HAL_SPI_Transmit(&hspi2,(uint8*)val2,num2,500);
    return sta==HAL_OK?SCNS_STATUS_OK:SCNS_STATUS_BSP_FAILED;
}

void scnsBspW25qxxSpiSetCs(ScnsW25qxxEnum w25N,uint8 dat)
{
    FLASH_CS_GPIO_Port->BSRR=(dat)?(FLASH_CS_Pin):(FLASH_CS_Pin<<16);
}

#endif
